// GlmfcnDoc.cpp : implementation of the CGlmfcnDoc class
//

#include "stdafx.h"
#include "Glmfcn.h"

#include "GlmfcnDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGlmfcnDoc

IMPLEMENT_DYNCREATE(CGlmfcnDoc, CDocument)

BEGIN_MESSAGE_MAP(CGlmfcnDoc, CDocument)
	//{{AFX_MSG_MAP(CGlmfcnDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGlmfcnDoc construction/destruction

CGlmfcnDoc::CGlmfcnDoc()
{
	// TODO: add one-time construction code here

}

CGlmfcnDoc::~CGlmfcnDoc()
{
}

BOOL CGlmfcnDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// Reinitialization of cone variables (when it starts for first time)
	//
	coneRadius = 0.5; // set radius
	coneHeight = 1.0; // set height
	coneSpin = 15.0; // set spin
	
	// Set cone starting color
	coneRedValue = 1.0; 
	coneGreenValue = 1.0;
	coneBlueValue = 1.0;

	// Set light position
	coneLightPositionX = 0.0;
	coneLightPositionY = 0.0;
	coneLightPositionZ = 1.0;

	// (SDI documents will reuse this document)
	m_pDC=NULL;

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CGlmfcnDoc serialization

void CGlmfcnDoc::Serialize(CArchive& ar)
{
	// Declaring string variable for reading line from text file
	CString line;

	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// Reading from the text file
		// In the first line read cone radius
		ar.ReadString(line);
		sscanf(line, "%f", &coneRadius);

		// In the second line read cone height
		ar.ReadString(line);
		sscanf(line, "%f", &coneHeight);
		
		// In the third line read cone color in format RGB
		ar.ReadString(line);
		sscanf(line, "%f %f %f", &coneRedValue, &coneGreenValue, &coneBlueValue);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CGlmfcnDoc diagnostics

#ifdef _DEBUG
void CGlmfcnDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CGlmfcnDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CGlmfcnDoc commands
